// 角色管理相关API
import http from '@/utils/request'

// API基础路径
const API_BASE = '/role'

/**
 * 获取角色列表
 */
export const getRoleListApi = (params) => {
  return http.get(`${API_BASE}/list`, params)
}

/**
 * 创建角色
 */
export const createRoleApi = (data) => {
  return http.post(`${API_BASE}/create`, data)
}

/**
 * 更新角色
 */
export const updateRoleApi = (data) => {
  return http.put(`${API_BASE}/update`, data)
}

/**
 * 删除角色
 */
export const deleteRoleApi = (id) => {
  return http.delete(`${API_BASE}/delete`, { id })
}

/**
 * 获取角色详情
 */
export const getRoleDetailApi = (id) => {
  return http.get(`${API_BASE}/detail`, { id })
}

/**
 * 分配角色权限
 */
export const assignPermissionsApi = (data) => {
  return http.post(`${API_BASE}/permissions`, data)
}

/**
 * 获取角色权限
 */
export const getRolePermissionsApi = (roleId) => {
  return http.get(`${API_BASE}/permissions`, { roleId })
}

/**
 * 获取角色用户列表
 */
export const getRoleUsersApi = (roleId, params = {}) => {
  return http.get(`${API_BASE}/users`, { roleId, ...params })
}

/**
 * 设置角色数据权限
 */
export const setRoleDataScopeApi = (data) => {
  return http.post(`${API_BASE}/data-scope`, data)
}

/**
 * 设置角色密码修改权限
 */
export const setPasswordPermissionApi = (data) => {
  return http.post(`${API_BASE}/password-permission`, data)
}

/**
 * 批量删除角色
 */
export const batchDeleteRolesApi = (ids) => {
  return http.delete(`${API_BASE}/batch-delete`, { ids })
}

/**
 * 获取所有角色(不分页)
 */
export const getAllRolesApi = () => {
  return http.get(`${API_BASE}/all`)
} 